/**
 * 删除广告
 * @param id
 * @param callback
 * @param loading
 */
function doDelAd(id, callback, loading) {
    var data = {
        "id": id
    };
    var url = $.domain + "/Console/Ad/doDel";
    sApi(url, data, callback, loading);
}

/**
 * 开启广告
 * @param {*} id 
 * @param {*} callback 
 * @param {*} loading 
 */
function doOpenAd(id, callback, loading) {
    var data = {
        "id": id
    };
    var url = $.domain + "/Console/Ad/doOpen";
    sApi(url, data, callback, loading);
}

/**
 * 编辑广告
 * @param id
 * @param data
 * @param callback
 * @param loading
 */
function doEditAd(id, data, callback, loading) {
    data = $.extend(data, {
        "id": id
    })
    var url = $.domain + "/Console/Ad/doEdit";
    sApi(url, data, callback, loading);
}

/**
 * 添加一条广告
 * @param data
 * @param callback
 * @param loading
 */
function doAddAd(data, callback, loading) {
    var url = $.domain + "/Console/Ad/doAdd";
    sApi(url, data, callback, loading);
}

/**
 * 获取广告列表
 * @param data
 * @param callback
 * @param loading
 */
function doGetAdList(data, callback, loading) {
    var url = $.domain + "/Console/Ad/doGetList";
    sApi(url, data, callback, loading);
}


/**
 * api调用
 * @param url
 * @param data
 * @param callback
 * @param loading
 */
function sApi(url, data, callback, loading) {
    if (typeof callback !== "function") {
        callback = emptyFunc;
    }

    if (typeof loading == "undefined") {
        loading = true;
    }

    var param = {
        "url": url,
        "data": data,
        "success": function (res) {
            if (!res) {
                res = errRes("网络响应超时");
            }
            callback(res);
        },
        "error": function () {
            callback(errRes("网络响应超时"));
        },
        "loading": loading ? true : false
    };
    $.sAjax(param);
}